package com.portal.framework.util;
/**
 * Html常用工具类 * @author 卢烁波
 * @date 2007-3-10
 */
public class HtmlUtil {

	/**
	 * 把带html标签的字符串格式化
	 * @param str
	 * @return
	 * @author 袁金锋
	 */
	public static String formatHtml(String str) {
		if (str == null) {
			return "";
		}
		String temp = str;
		temp = temp.replaceAll("<br>", "\n");
		temp = temp.replaceAll("&nbsp;&nbsp;", "   ");
		temp = temp.replaceAll("&lt;", "<");
		temp = temp.replaceAll("&gt;", ">");
		return temp;
	}
	/**
	 * 把带html标签的字符串格式化
	 * @param str
	 * @return
	 * @author 袁金锋
	 */ 
	public static String formatStrToHtml(String str) {
		if (str == null) {
			return "";
		}
		String temp = str;
		temp = temp.replaceAll("\n", "<br>");
		temp = temp.replaceAll("   ", "&nbsp;&nbsp;");
		temp = temp.replaceAll("<", "&lt;");
		temp = temp.replaceAll(">", "&gt;");
		return temp;
	}
	
}
